package com.qcby.controller;

import com.qcby.common.WrongQuestion.ShowByPage;
import com.qcby.entity.ErrorCollection;
import com.qcby.entity.Result;
import com.qcby.service.WrongQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@Api(tags = "错题集接口")
@RequestMapping("/WrongQuestion")
public class WrongQuestionController {

    @Autowired
    WrongQuestionService wrongQuestionService;

    @PostMapping("/ShowErrorCollectionByPage")
    @ApiOperation(value = "展示错题集")
    @ResponseBody
    public Result<List<ErrorCollection>> showErrorCollectionByPage(ShowByPage info){
        return wrongQuestionService.showErrorCollectionByPage(info);
    }

    @PostMapping("/GetErrorCollectionCount")
    @ApiOperation(value = "获取错题数量")
    @ResponseBody
    public Result<Integer> getErrorCollectionCount(String student){
        return wrongQuestionService.getErrorCollectionCount(student);
    }

    @DeleteMapping("/DeleteErrorCollection")
    @ApiOperation(value = "删除错题")
    @ResponseBody
    public Result<Integer> deleteErrorCollection(int id){
        return wrongQuestionService.deleteErrorCollection(id);
    }

    @ApiModelProperty(value = "根据ids找到错题")
    @PostMapping("/GetWrongQuestionByIds")
    @ResponseBody
    public Result<List<ErrorCollection>> GetWrongQuestionByIds(@RequestBody List<Integer> list){
        System.out.println(list);
        return Result.success(wrongQuestionService.GetWrongQuestionByIds(list));
    }
}
